package com.yonyou.sto.modules.ims.service.impl;

import cn.hutool.json.JSONObject;
import com.yonyou.sto.modules.ims.dto.CallbackInvoiceParam;
import com.yonyou.sto.modules.ims.service.CacheService;
import com.yonyou.sto.modules.ims.service.OpenBillService;
import net.jodah.expiringmap.ExpirationListener;
import net.jodah.expiringmap.ExpirationPolicy;
import net.jodah.expiringmap.ExpiringMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

/**
 * @文件名: com.yonyou.sto.modules.ims.service.impl
 * @创建用户: MagicJava
 * @项目名: feikai-back
 * @date 2023/4/18 16:50
 */
@Service
public class CacheServiceIpm implements CacheService {
    @Autowired
    OpenBillService openBillService;
    public static final ExpiringMap<String, CallbackInvoiceParam> Token_Cache = ExpiringMap.builder()
            .maxSize(1000)
            .expiration(300, TimeUnit.SECONDS)
            .variableExpiration()
            .expirationPolicy(ExpirationPolicy.CREATED)
            .build();


    @Override
    public  ExpiringMap<String, CallbackInvoiceParam> getCahe() {

        //Token_Cache.addExpirationListener(expirationListener);
        ExpiringMap<String, CallbackInvoiceParam> cache = Token_Cache;
        return cache;
    }
}
